package dao.implementations.postgresql.Socio;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import dao.implementations.DBBase;
import dao.interfaces.Socio.ISocio;

public class SocioDB extends DBBase implements ISocio {
	
	public SocioDB(Connection connection){
		this.conn = connection;
	}
	
	@Override
	public int eliminarSocio(int rut) {
		PreparedStatement ps = null;
		int result = -1;
		
		String query = "DELETE FROM socio WHERE rut_socio=?";
		
		try{
			ps = this.conn.prepareStatement(query);
			ps.setInt(1, rut);
			
			result = ps.executeUpdate();
		}
		catch (SQLException ex)
		{
			System.out.println("Error en la clase SocioDB -> eliminarSocio -> "+ ex.getMessage());
		}		
		return result;
	}
}
